import { ElMessage, ElMessageBox } from 'element-plus'
// 全局封装提示

export const $msg_success = (message:string, duration = 1000) => {
    ElMessage({
        showClose: true,
        message,
        duration,
        type: 'success',
    })
}

export const $msg_warning = (message:string, duration = 1000) => {
    ElMessage({
        showClose: true,
        message,
        duration,
        type: 'warning',
    })
}

export const $msg_error = ( message:string, duration = 2000) => {
    ElMessage({
        showClose: true,
        message,
        duration,
        type: 'error',
    })
}

export const $confirm = ( message:string, title = '提示', type = 'warning') => {
     /*ElMessageBox.confirm(
        message,
        title,
        {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type,
        }
    ).then(() => { resolve(); })
        .catch(() => { })
*/
   return new Promise((resolve, reject) => {
    // 未知 type 的错误
        ElMessageBox.confirm(
            message,
            title,
            {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type,
                // draggable: true,
            }
        ).then(() => { resolve(); })
            .catch(() => { })
    })
    
}